import {
  wxRequest
} from '../../utils/server.js';
const _wxRequest = new wxRequest();
const app = getApp()
Page({
  data: {
    imgUrl: app.globalData.imgUrl,
    uploadUrl: wx.getStorageSync('uploadUrl'),
    list: [],
    pageNo: 1,
    hasNextPage: false, 
  },
 
  onShow: function () {
    this.getlist()
  },
 
  //获取列表 
  getlist: function () {
    _wxRequest.wxTonkenAjax({
      url: app.globalData.apiUrl + '/odr/protected/order/findPreheatPresent?pageNo=' + this.data.pageNo,
      method: 'POST',
    }, (res) => {
      
      var list = res.list
      if (this.data.pageNo !== 1) {
        list = this.data.list.concat(list);
      }
      console.log(list)
      this.setData({
        list: list,
        // pageNo: res.page.pageNo || 1,
        // hasNextPage: res.page.hasNextPage || false,
      });
    })
  },

   

  //下拉刷新
  onPullDownRefresh: function () {
    this.refreshData();
    wx.stopPullDownRefresh()
  },

  refreshData: function () {
    this.setData({
      pageNo: 1
    })
    this.getlist();
  },

  //触底时，加载更多
  onReachBottom: function () {
    if (this.data.hasNextPage) {
      this.setData({
        pageNo: this.data.pageNo + 1
      });
      this.getlist();
    }
  },



  //查看详情 
  handleDetail: function (e) {
    wx.navigateTo({
      url: '/pages/good/detail/index?id=' + e.currentTarget.dataset.id
    })
  },
 
})